/*
 * @Author: Yejing
 * @Date: 2023-05-10 17:17:41
 * @LastEditors: Yejing
 * @LastEditTime: 2023-06-16 16:16:21
 * @Description: tab联动
 */
<template>
	<view class="tab-wrap">
		<view class="tab-item" v-for="(item,index) in tabList" :key="index"
			:class="{'active':index==curTabIndex?true:false}" @click="tabChange(index)">
			{{item}}
		</view>
	</view>
</template>
<script>
	export default {
		props: {
			//切换卡列表
			tabList: {
				type: Array,
				default: []
			}
		},
		data() {
			return {
				curTabIndex: 0
			}
		},
		methods: {
			//点击
			tabChange(index) {
				this.curTabIndex = index;
				this.$emit('change', index);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab-wrap {
		height: 80rpx;
		color: #333;
		display: flex;
		font-size: 28rpx;
		padding-bottom: 20rpx;
		overflow-x: scroll;
		z-index: 999;
		background: #fff;
		width: calc(100vw - 65rpx);

		.tab-item {
			min-width: 200rpx;
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			transition: all .3s ease-in-out;
			border-bottom: 3px solid transparent;
		}

		.active {
			position: relative;
			color: #2934D0;

			&::after {
				position: absolute;
				content: '';
				width: 100%;
				height: 6rpx;
				left: 50%;
				transform: translateX(-50%);
				bottom: -8rpx;
				background-color: #2934D0;
			}
		}
	}
</style>